*************************************************
***                Basic setup                ***
*************************************************
clear all
set more off, permanent
capture log close

/* user to replace with own paths 
global Other = 0
global IP = 1


if $Other == 1 {
global path_work "/Users/lxxk/3.RA/CCP/RE and Mediation/replication"
global path_log "/Users/lxxk/3.RA/CCP/log"
global out "/Users/lxxk/3.RA/CCP/RE and Mediation/replication"
global date : di %tdCCYYNNDD date(c(current_date), "DMY") 
log using "$path_log/elite_$date.txt", text replace
cd "$path_work"
}


if $IP == 1 {
 global gdrive: env google
 global work "$gdrive\Research\China-CCP\"
 global out "$gdrive\Research\China-CCP\Stata-out\"
 cd "$work\Stata\"
 global date : di %tdCCYYNNDD date(c(current_date), "DMY") 
 log using "mediation.log" , text replace
}

cd "$work\replication\"
*/

*************************************************
***                Import Data                ***
*************************************************
use "elite.dta", clear
global nomissingdata inlist(uid1937, ///
    320101, 320102, 320104, 320203, 320206, 320301, 320309, /// 
    320401, 320402, 320405, 320501, 320505, 320602, 320604, /// 
    320702, 320705, 320802, 320805, 321003, 340102, 340104, /// 
    340105, 340201, 340203, 340204, 340301, 340303, 340304, /// 
    340403, 340404, 340502, 340503, 340504, 340506, 340604, /// 
    340803, 340901, 340903, 340906, 341001, 341004, 341005, ///
    410108, 410206, 410212, 410401, 410404, 410411, 410606, /// 
    410701, 410706, 410707, 410906, 411003, 411106)






*************************************************
***                  Table 3                  ***
*************************************************
global clogitopt group(uid1937) vce(cluster uid1937)
global depvar ccpf

global outopt landscape plain coljust(lc) varlabels se starloc(1) ///
  starlevels(10 5 1) /// 
  addrows("County fixed effects" , "Yes" \ "Year fixed effects", "Yes") ///
  summstat(N \ N_clust \ ll \ r2_p) summtitle(Observations \ Counties \ Log likelihood \ Pseudo R-squared) 
global outopt2 landscape plain coljust(lc) varlabels se starloc(1) ///
  starlevels(10 5 1) bdec(3) noautosumm
global tablenote ///
  note("Estimated by logit (Stata routine, clogit) with fixed effects for county and year; Dependent variable: Presence of CCP County Committee in following year. Estimates in columns (6) and (7) include control for missing explanatory variable (ruggedness and tenancy respectively). Robust standard errors clustered by county in parentheses (***p<0.01 **p<0.05 *p < 0.1). Effect size is the effect on the odds of CCP presence associated with a one standard deviation increase in the explanatory variable") 
outreg, clear(t3)



*------------ (1) Japanese invasion ------------*
clogit $depvar jap i.year , $clogitopt
outreg, merge(t3) $outopt keep(jap) ctitle("", "(1) Japanese invasion")

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC



*------------- (2) CCP leadership -------------*
clogit $depvar jap ccpfight armyccp ccpfight_jap armyccp_jap i.year , $clogitopt
outreg, merge(t3) $outopt keep(jap ccpfight ccpfight_jap armyccp armyccp_jap) ///
  ctitle("", "(2) CCP leadership")

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC



*-------- (3) CCP socio-economic reform --------*
clogit $depvar jap reform reform_jap i.year , $clogitopt
outreg, merge(t3) $outopt keep(jap reform reform_jap) ///
  ctitle("", "(3) CCP socio-economic reform")

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum reform if e(sample)
local reform_sd = round(r(sd), .001)
local reform_coef = round(_b[reform], .001)
local effect = exp(`reform_sd'*`reform_coef')
di "Effect size: Militia x Japan " round(`effect', .001)



*------------ (4) CCP mobilization -------------*
clogit $depvar jap mblzccp mblzccp_jap i.year , $clogitopt
outreg, merge(t3) $outopt keep(jap mblzccp mblzccp_jap) ///
  ctitle("", "(4) CCP mobilization")

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum mblzccp if e(sample)
local mblzccp_sd = round(r(sd), .001)
local mblzccp_coef = round(_b[mblzccp], .001)
local effect = exp(`mblzccp_sd'*`mblzccp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)



*--------------- (5) CCP combined --------------*
clogit $depvar jap ccpfight ccpfight_jap armyccp armyccp_jap ///
reform reform_jap mblzccp mblzccp_jap i.year , $clogitopt
outreg, merge(t3) $outopt keep(jap ccpfight ccpfight_jap armyccp armyccp_jap ///
  reform reform_jap mblzccp mblzccp_jap) ///
  ctitle("", "(5) CCP combined")

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum reform if e(sample)
local reform_sd = round(r(sd), .001)
local reform_coef = round(_b[reform], .001)
local effect = exp(`reform_sd'*`reform_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum mblzccp if e(sample)
local mblzccp_sd = round(r(sd), .001)
local mblzccp_coef = round(_b[mblzccp], .001)
local effect = exp(`mblzccp_sd'*`mblzccp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)



*---------- (6) Ruggedness of terrain -----------*
clogit $depvar jap ruggedness_jap ruggedness_mi_jap i.year , $clogitopt
outreg, merge(t3) $outopt keep(jap ruggedness_jap ruggedness_mi_jap) ///
  ctitle("", "(6) Rugged-ness of terrain")

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC



*----------------- (7) Tenancy ------------------*
clogit $depvar jap tenant_jap tenant_mi_jap i.year , $clogitopt
outreg, merge(t3) $outopt keep(jap tenant_jap tenant_mi_jap) ///
  ctitle("", "(7) Tenancy")

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC
outreg using "$out/table3_$date.doc" , $outopt2 replay(t3) ///
  title("Table 3 Conventional explanations") replace $tablenote





*************************************************
***                  Table 4                  ***
*************************************************
global clogitopt group(uid1937) vce(cluster uid1937)
global depvar ccpf

global outopt landscape plain coljust(lc) varlabels se starloc(1) ///
  starlevels(10 5 1) /// 
  addrows("County fixed effects" , "Yes" \ "Year fixed effects", "Yes") ///
  summstat(N \ N_clust \ ll \ r2_p) summtitle(Observations \ Counties \ Log likelihood \ Pseudo R-squared) 
global outopt2 landscape plain coljust(lc) varlabels se starloc(1) ///
  starlevels(10 5 1) bdec(3) noautosumm
global tablenote ///
  note("Estimated by logit (Stata routine, clogit) with fixed effects for county and year; Dependent variable: presence of CCP County Committee in following year. Security forces are a proxy for state penetration and excess tax rate is a proxy for state resource extraction. All estimates control for data of explanatory variables (security forces, gentry, and excess tax – each interacted with Japanese invasion) being missing. Robust standard errors clustered by county in parentheses (***p<0.01 **p<0.05 *p<0.1). Effect size is calculated as the effect of one standard deviation increase in the explanatory variable on the odds of CCP control over no-CCP control. Mediation effect of excess tax calculated by the Kohler et al. (2011) method (Stata routine, khb)") 
outreg, clear(t4)



*------------ (1) Japanese invasion ------------*
clogit $depvar jap i.year , $clogitopt
outreg , $outopt merge(t4) ///
  keep(jap) ///
  ctitle("VARIABLES", "(1) Japanese invasion")   

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC



*---------- (2) Militia and excess tax ---------*
clogit $depvar jap m_jp m_mi_jp t_jp t_mi_jp i.year ///
  , $clogitopt
outreg , $outopt merge(t4) ///
  keep(jap m_jp t_jp) ///
  ctitle("VARIABLES", "(2) Militia and excess tax")   

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum m_jp if e(sample)
local m_jp_sd = round(r(sd), .001)
local m_jp_coef = round(_b[m_jp], .001)
local effect = exp(`m_jp_sd'*`m_jp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)

khb clogit $depvar m_jp || t_jp if e(sample), ///
    concomitant(jap m_mi_jp t_mi_jp i.year) $clogitopt summary
local m_jp_reduced = _b[m_jp:Reduced]
local m_jp_diff = _b[m_jp:Diff]
local m_jp_medprop = `m_jp_diff' / `m_jp_reduced'
di "The Excess tax x Japan mediated Militia x Japan by " round(`m_jp_medprop', .001)*100 "%"



*---------- (3) Gentry and excess tax ---------*
clogit $depvar jap g1_jp g1_mi_jp t_jp t_mi_jp i.year ///
   ,  $clogitopt
outreg , $outopt merge(t4) ///
  keep(jap g1_jp t_jp) ///
  ctitle("VARIABLES", "(3) Gentry and excess tax") 

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum g1_jp if e(sample)
local g1_jp_sd = round(r(sd), .001)
local g1_jp_coef = round(_b[g1_jp], .001)
local effect = exp(`g1_jp_sd'*`g1_jp_coef')
di "Effect size: Gentry x Japan  " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)

khb clogit $depvar g1_jp || t_jp if e(sample), ///
    concomitant(jap g1_mi_jp t_mi_jp i.year) $clogitopt summary

local g1_jp_reduced = _b[g1_jp:Reduced]
local g1_jp_diff = _b[g1_jp:Diff]
local g1_jp_medprop = `g1_jp_diff' / `g1_jp_reduced'
di "The Excess tax x Japan mediated Gentry x Japan by " round(`g1_jp_medprop', .001)*100 "%"



*------------ (4) Combined estimate -----------*
clogit $depvar jap m_jp m_mi_jp g1_jp g1_mi_jp t_jp t_mi_jp i.year ///
  , $clogitopt
outreg , $outopt merge(t4) ///
  keep(jap m_jp g1_jp t_jp) ///
  ctitle("VARIABLES", "(4) Combined estimate")    

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC 

sum m_jp if e(sample)
local m_jp_sd = round(r(sd), .001)
local m_jp_coef = round(_b[m_jp], .001)
local effect = exp(`m_jp_sd'*`m_jp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum g1_jp if e(sample)
local g1_jp_sd = round(r(sd), .001)
local g1_jp_coef = round(_b[g1_jp], .001)
local effect = exp(`g1_jp_sd'*`g1_jp_coef')
di "Effect size: Gentry x Japan  " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)

khb clogit $depvar m_jp g1_jp || t_jp if e(sample), ///
    concomitant(jap m_mi_jp g1_mi_jp t_mi_jp i.year) $clogitopt summary
local m_jp_reduced = _b[m_jp:Reduced]
local m_jp_diff = _b[m_jp:Diff]
local m_jp_medprop = `m_jp_diff' / `m_jp_reduced'
di "The Excess tax x Japan mediated Militia x Japan by " round(`m_jp_medprop', .001)*100 "%"

local g1_jp_reduced = _b[g1_jp:Reduced]
local g1_jp_diff = _b[g1_jp:Diff]
local g1_jp_medprop = `g1_jp_diff' / `g1_jp_reduced'
di "The Excess tax x Japan mediated Gentry x Japan by " round(`g1_jp_medprop', .001)*100 "%"



/*------------ (5) No missing data -----------*/
clogit $depvar jap m_jp g1_jp t_jp i.year ///
  if $nomissingdata , $clogitopt
outreg , $outopt merge(t4) ///
  keep(jap m_jp g1_jp t_jp) ///
  ctitle("VARIABLES", "(5) No missing data")

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC 

sum m_jp if e(sample)
local m_jp_sd = round(r(sd), .001)
local m_jp_coef = round(_b[m_jp], .001)
local effect = exp(`m_jp_sd'*`m_jp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum g1_jp if e(sample)
local g1_jp_sd = round(r(sd), .001)
local g1_jp_coef = round(_b[g1_jp], .001)
local effect = exp(`g1_jp_sd'*`g1_jp_coef')
di "Effect size: Gentry x Japan  " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)
  
khb clogit $depvar m_jp g1_jp || t_jp if $nomissingdata , ///
    concomitant(jap i.year) $clogitopt summary
local m_jp_reduced = _b[m_jp:Reduced]
local m_jp_diff = _b[m_jp:Diff]
local m_jp_medprop = `m_jp_diff' / `m_jp_reduced'
di "The Excess tax x Japan mediated Militia x Japan by " round(`m_jp_medprop', .001)*100 "%"

local g1_jp_reduced = _b[g1_jp:Reduced]
local g1_jp_diff = _b[g1_jp:Diff]
local g1_jp_medprop = `g1_jp_diff' / `g1_jp_reduced'
di "The Excess tax x Japan mediated Gentry x Japan by " round(`g1_jp_medprop', .001)*100 "%"
outreg using "$out/table4_$date.doc" , $outopt2 replay(t4) ///
  title("Table 4 Tocqueville-Fei perspective") replace $tablenote





*************************************************
***                  Table 5                  ***
*************************************************
global clogitopt group(uid1937) vce(cluster uid1937)
global depvar ccpf

global outopt landscape plain coljust(lc) varlabels se starloc(1) ///
  starlevels(10 5 1) /// 
  addrows("County fixed effects" , "Yes" \ "Year fixed effects", "Yes") ///
  summstat(N \ N_clust \ ll \ r2_p) summtitle(Observations \ Counties \ Log likelihood \ Pseudo R-squared) 
global outopt2 landscape plain coljust(lc) varlabels se starloc(1) ///
  starlevels(10 5 1) bdec(3) noautosumm
global tablenote ///
  note("Estimated by logit (Stata routine, clogit) with fixed effects for county and year; Dependent variable: Presence of CCP County Committee in following year. Security forces are a proxy for state penetration and excess tax rate is a proxy for state resource extraction. All estimates control for data of explanatory variables (security forces, gentry, and excess tax – each interacted with Japanese invasion) being missing. Robust standard errors clustered by county in parentheses (***p < 0.01 **p < 0.05 *p < 0.1). Effect size is calculated as the effect of one standard deviation increase in the explanatory variable on the odds of CCP control over no-CCP control. Mediation effect of excess tax calculated by the Kohler et al. (2011) method (Stata routine, khb)" ) 

outreg, clear(t5)



*------------ (1) Japanese invasion -----------*
clogit $depvar jap m_jp m_mi_jp g1_jp g1_mi_jp t_jp t_mi_jp ///
  i.year, $clogitopt
outreg , $outopt merge(t5) ///
  keep(jap m_jp g1_jp t_jp) ///
  ctitle("VARIABLES", "(1) Preferred estimate")   


estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC


sum m_jp if e(sample)
local m_jp_sd = round(r(sd), .001)
local m_jp_coef = round(_b[m_jp], .001)
local effect = exp(`m_jp_sd'*`m_jp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum g1_jp if e(sample)
local g1_jp_sd = round(r(sd), .001)
local g1_jp_coef = round(_b[g1_jp], .001)
local effect = exp(`g1_jp_sd'*`g1_jp_coef')
di "Effect size: Gentry x Japan  " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)

khb clogit $depvar m_jp g1_jp || t_jp, ///
    concomitant(jap m_mi_jp g1_mi_jp t_mi_jp i.year) $clogitopt summary
local m_jp_reduced = _b[m_jp:Reduced]
local m_jp_diff = _b[m_jp:Diff]
local m_jp_medprop = `m_jp_diff' / `m_jp_reduced'
di "The Excess tax x Japan mediated Militia x Japan by " round(`m_jp_medprop', .001)*100 "%"

local g1_jp_reduced = _b[g1_jp:Reduced]
local g1_jp_diff = _b[g1_jp:Diff]
local g1_jp_medprop = `g1_jp_diff' / `g1_jp_reduced'
di "The Excess tax x Japan mediated Gentry x Japan by " round(`g1_jp_medprop', .001)*100 "%"



*--------- (2) CCP socio-econ reform ----------*
clogit $depvar jap m_jp m_mi_jp g1_jp g1_mi_jp t_jp t_mi_jp ///
  reform reform_jap ///
  i.year, $clogitopt
outreg , $outopt merge(t5) ///
  keep(jap m_jp g1_jp t_jp ///
       reform reform_jap) ///
  ctitle("VARIABLES", "(2) CCP socio-econ reform")   


estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum m_jp if e(sample)
local m_jp_sd = round(r(sd), .001)
local m_jp_coef = round(_b[m_jp], .001)
local effect = exp(`m_jp_sd'*`m_jp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum g1_jp if e(sample)
local g1_jp_sd = round(r(sd), .001)
local g1_jp_coef = round(_b[g1_jp], .001)
local effect = exp(`g1_jp_sd'*`g1_jp_coef')
di "Effect size: Gentry x Japan  " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)


khb clogit $depvar m_jp g1_jp || t_jp, ///
    concomitant(jap m_mi_jp g1_mi_jp t_mi_jp ///
                reform reform_jap i.year) $clogitopt summary
local m_jp_reduced = _b[m_jp:Reduced]
local m_jp_diff = _b[m_jp:Diff]
local m_jp_medprop = `m_jp_diff' / `m_jp_reduced'
di "The Excess tax x Japan mediated Militia x Japan by " round(`m_jp_medprop', .001)*100 "%"

local g1_jp_reduced = _b[g1_jp:Reduced]
local g1_jp_diff = _b[g1_jp:Diff]
local g1_jp_medprop = `g1_jp_diff' / `g1_jp_reduced'
di "The Excess tax x Japan mediated Gentry x Japan by " round(`g1_jp_medprop', .001)*100 "%"


*------------ (3) CCP mobilization ------------*
clogit $depvar jap m_jp m_mi_jp g1_jp g1_mi_jp t_jp t_mi_jp ///
  mblzccp mblzccp_jap ///
  i.year, $clogitopt
outreg , $outopt merge(t5) ///
  keep(jap m_jp g1_jp t_jp ///
       mblzccp mblzccp_jap) ///
  ctitle("VARIABLES", "(3) CCP mobilization")   


estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum m_jp if e(sample)
local m_jp_sd = round(r(sd), .001)
local m_jp_coef = round(_b[m_jp], .001)
local effect = exp(`m_jp_sd'*`m_jp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum g1_jp if e(sample)
local g1_jp_sd = round(r(sd), .001)
local g1_jp_coef = round(_b[g1_jp], .001)
local effect = exp(`g1_jp_sd'*`g1_jp_coef')
di "Effect size: Gentry x Japan  " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)

khb clogit $depvar m_jp g1_jp || t_jp, ///
    concomitant(jap m_mi_jp g1_mi_jp t_mi_jp ///
                mblzccp mblzccp_jap i.year) $clogitopt summary
local m_jp_reduced = _b[m_jp:Reduced]
local m_jp_diff = _b[m_jp:Diff]
local m_jp_medprop = `m_jp_diff' / `m_jp_reduced'
di "The Excess tax x Japan mediated Militia x Japan by " round(`m_jp_medprop', .001)*100 "%"

local g1_jp_reduced = _b[g1_jp:Reduced]
local g1_jp_diff = _b[g1_jp:Diff]
local g1_jp_medprop = `g1_jp_diff' / `g1_jp_reduced'
di "The Excess tax x Japan mediated Gentry x Japan by " round(`g1_jp_medprop', .001)*100 "%"



*------------- (4) CCP leadership -------------*
clogit $depvar jap m_jp m_mi_jp g1_jp g1_mi_jp t_jp t_mi_jp ///
  ccpfight armyccp ccpfight_jap armyccp_jap ///
  i.year, $clogitopt
outreg , $outopt merge(t5) ///
  keep(jap m_jp g1_jp t_jp ///
       ccpfight armyccp ccpfight_jap armyccp_jap) ///
  ctitle("VARIABLES", "(4) CCP leadership")   


estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum m_jp if e(sample)
local m_jp_sd = round(r(sd), .001)
local m_jp_coef = round(_b[m_jp], .001)
local effect = exp(`m_jp_sd'*`m_jp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum g1_jp if e(sample)
local g1_jp_sd = round(r(sd), .001)
local g1_jp_coef = round(_b[g1_jp], .001)
local effect = exp(`g1_jp_sd'*`g1_jp_coef')
di "Effect size: Gentry x Japan  " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)


khb clogit $depvar m_jp g1_jp || t_jp, ///
    concomitant(jap m_mi_jp g1_mi_jp t_mi_jp i.year ///
                ccpfight armyccp ccpfight_jap armyccp_jap) $clogitopt summary
local m_jp_reduced = _b[m_jp:Reduced]
local m_jp_diff = _b[m_jp:Diff]
local m_jp_medprop = `m_jp_diff' / `m_jp_reduced'
di "The Excess tax x Japan mediated Militia x Japan by " round(`m_jp_medprop', .001)*100 "%"

local g1_jp_reduced = _b[g1_jp:Reduced]
local g1_jp_diff = _b[g1_jp:Diff]
local g1_jp_medprop = `g1_jp_diff' / `g1_jp_reduced'
di "The Excess tax x Japan mediated Gentry x Japan by " round(`g1_jp_medprop', .001)*100 "%"



*---------- (5) Historical CCP ---------*
clogit $depvar jap m_jp m_mi_jp g1_jp g1_mi_jp t_jp t_mi_jp ///
  pre_ccp_jap i.year, $clogitopt
outreg , $outopt merge(t5) ///
  keep(jap m_jp g1_jp t_jp pre_ccp_jap) ///
  ctitle("VARIABLES", "(5) Historical CCP")   

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum m_jp if e(sample)
local m_jp_sd = round(r(sd), .001)
local m_jp_coef = round(_b[m_jp], .001)
local effect = exp(`m_jp_sd'*`m_jp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum g1_jp if e(sample)
local g1_jp_sd = round(r(sd), .001)
local g1_jp_coef = round(_b[g1_jp], .001)
local effect = exp(`g1_jp_sd'*`g1_jp_coef')
di "Effect size: Gentry x Japan  " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)


khb clogit $depvar m_jp g1_jp || t_jp, ///
    concomitant(jap m_mi_jp g1_mi_jp t_mi_jp i.year ///
                pre_ccp_jap) $clogitopt summary
local m_jp_reduced = _b[m_jp:Reduced]
local m_jp_diff = _b[m_jp:Diff]
local m_jp_medprop = `m_jp_diff' / `m_jp_reduced'
di "The Excess tax x Japan mediated Militia x Japan by " round(`m_jp_medprop', .001)*100 "%"

local g1_jp_reduced = _b[g1_jp:Reduced]
local g1_jp_diff = _b[g1_jp:Diff]
local g1_jp_medprop = `g1_jp_diff' / `g1_jp_reduced'
di "The Excess tax x Japan mediated Gentry x Japan by " round(`g1_jp_medprop', .001)*100 "%"



*---------- (6) Ruggedness of terrain ---------*
clogit $depvar jap m_jp m_mi_jp g1_jp g1_mi_jp t_jp t_mi_jp ///
  ruggedness_jap ruggedness_mi_jap ///
  i.year, $clogitopt
outreg , $outopt merge(t5) ///
  keep(jap m_jp g1_jp t_jp ruggedness_jap) ///
  ctitle("VARIABLES", "(6) Terrain")   

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum m_jp if e(sample)
local m_jp_sd = round(r(sd), .001)
local m_jp_coef = round(_b[m_jp], .001)
local effect = exp(`m_jp_sd'*`m_jp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum g1_jp if e(sample)
local g1_jp_sd = round(r(sd), .001)
local g1_jp_coef = round(_b[g1_jp], .001)
local effect = exp(`g1_jp_sd'*`g1_jp_coef')
di "Effect size: Gentry x Japan  " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)


khb clogit $depvar m_jp g1_jp || t_jp, ///
    concomitant(jap m_mi_jp g1_mi_jp t_mi_jp i.year ///
                ruggedness_jap ruggedness_mi_jap) $clogitopt summary
local m_jp_reduced = _b[m_jp:Reduced]
local m_jp_diff = _b[m_jp:Diff]
local m_jp_medprop = `m_jp_diff' / `m_jp_reduced'
di "The Excess tax x Japan mediated Militia x Japan by " round(`m_jp_medprop', .001)*100 "%"

local g1_jp_reduced = _b[g1_jp:Reduced]
local g1_jp_diff = _b[g1_jp:Diff]
local g1_jp_medprop = `g1_jp_diff' / `g1_jp_reduced'
di "The Excess tax x Japan mediated Gentry x Japan by " round(`g1_jp_medprop', .001)*100 "%"



*---------------- (7) Tenancy -----------------*
clogit $depvar jap m_jp m_mi_jp g1_jp g1_mi_jp t_jp t_mi_jp ///
  tenant_jap tenant_mi_jap ///
  i.year, $clogitopt
outreg , $outopt merge(t5) ///
  keep(jap m_jp g1_jp t_jp tenant_jap) ///
  ctitle("VARIABLES", "(7) Tenancy")   

estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum m_jp if e(sample)
local m_jp_sd = round(r(sd), .001)
local m_jp_coef = round(_b[m_jp], .001)
local effect = exp(`m_jp_sd'*`m_jp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum g1_jp if e(sample)
local g1_jp_sd = round(r(sd), .001)
local g1_jp_coef = round(_b[g1_jp], .001)
local effect = exp(`g1_jp_sd'*`g1_jp_coef')
di "Effect size: Gentry x Japan  " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)



khb clogit $depvar m_jp g1_jp || t_jp, ///
    concomitant(jap m_mi_jp g1_mi_jp t_mi_jp i.year ///
                tenant_jap tenant_mi_jap) $clogitopt summary
local m_jp_reduced = _b[m_jp:Reduced]
local m_jp_diff = _b[m_jp:Diff]
local m_jp_medprop = `m_jp_diff' / `m_jp_reduced'
di "The Excess tax x Japan mediated Militia x Japan by " round(`m_jp_medprop', .001)*100 "%"

local g1_jp_reduced = _b[g1_jp:Reduced]
local g1_jp_diff = _b[g1_jp:Diff]
local g1_jp_medprop = `g1_jp_diff' / `g1_jp_reduced'
di "The Excess tax x Japan mediated Gentry x Japan by " round(`g1_jp_medprop', .001)*100 "%"


*------ (8) Admin district -----*
clogit $depvar jap m_jp m_mi_jp g1_jp g1_mi_jp t_jp t_mi_jp ///
  i.year, group(uid1937) vce(cluster ad1937)
outreg , $outopt merge(t5) ///
  keep(jap m_jp g1_jp t_jp)  ///
  ctitle("VARIABLES", "(8) Administrative districts")   


estat ic
matrix list r(S)
matrix S = r(S)
scalar BIC = round(S[1,6], 0.01)
disp BIC

sum m_jp if e(sample)
local m_jp_sd = round(r(sd), .001)
local m_jp_coef = round(_b[m_jp], .001)
local effect = exp(`m_jp_sd'*`m_jp_coef')
di "Effect size: Militia x Japan " round(`effect', .001)

sum g1_jp if e(sample)
local g1_jp_sd = round(r(sd), .001)
local g1_jp_coef = round(_b[g1_jp], .001)
local effect = exp(`g1_jp_sd'*`g1_jp_coef')
di "Effect size: Gentry x Japan  " round(`effect', .001)

sum t_jp if e(sample)
local t_jp_sd = round(r(sd), .001)
local t_jp_coef = round(_b[t_jp], .001)
local effect = exp(`t_jp_sd'*`t_jp_coef')
di "Effect size: Excess tax x Japan " round(`effect', .001)


khb clogit $depvar m_jp g1_jp || t_jp, ///
    concomitant(jap m_mi_jp g1_mi_jp t_mi_jp i.year) group(uid1937) vce(cluster ad1937) summary
local m_jp_reduced = _b[m_jp:Reduced]
local m_jp_diff = _b[m_jp:Diff]
local m_jp_medprop = `m_jp_diff' / `m_jp_reduced'
di "The Excess tax x Japan mediated Militia x Japan by " round(`m_jp_medprop', .001)*100 "%"

local g1_jp_reduced = _b[g1_jp:Reduced]
local g1_jp_diff = _b[g1_jp:Diff]
local g1_jp_medprop = `g1_jp_diff' / `g1_jp_reduced'
di "The Excess tax x Japan mediated Gentry x Japan by " round(`g1_jp_medprop', .001)*100 "%"


outreg using "$out/table5_$date.doc" , $outopt2 replay(t5) ///
  title("Table 5 Robustness checks") replace $tablenote


*************************************************
***                    End                    ***
*************************************************
log close

